'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
	//先查询手机号是否存在，短信验证码先不做
	let res = await db.collection('uni-id-users').where({
		"mobile": event.phone
	}).count()
	if (res.total == 1) {
		let res = await db.collection('uni-id-users').where({"mobile": event.phone}).update({
			"password": event.password
		})
		return {
			code: 200,
			msg: "密码修改成功",
			data: res.data
		}
	} else {
		return {
			code: 500,
			msg: "手机号尚未注册",
			data: res.data
		}
	}

};
